<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model="a">
        <input type="text" v-model="b"> {{a+b}}
    </div>
</body>
<!--如果写在data里  那么成字符串相加了 computed和data 里面的属性  不能重名 -->
<!-- 可缓存优化属性   不能异步 -->
<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data: () => {
            return {
                c: 0,
                d: 0
            }
        },
        
        methods: {
            dd(){
                alert(2)
            }
        },
        computed: {
            // a(){       //简写
            //     return 555;
            // },
            a:{
                get() {
                    return this.c;
                },
                set(newVal) {
                    this.c=parseInt(newVal)
                }
            },
            b: {
                get() {
                    return this.d;
                },
                set(newVal) {
                    this.d=parseInt(newVal)
                }
            }
        }
    })
</script>


</html>